#ifndef DATASTRUCT_H
#define DATASTRUCT_H
#include <QObject>
#include <QString>
#include <QList>
#include <QTime>
#include <QDateTime>
/******************************************
 * brief    非指针类型成员变量GetSet自动生成
 * param    type 类型
 * param    name 变量名
 * param    access_permission 权限
 * return   void
 ******************************************/
#define PropertyBuilderByName(type,name,access_permission)\
    access_permission:\
    type m_##name;\
    public:\
    inline void set##name(type v){m_##name = v;}\
    inline type get##name(){return m_##name;}\

/******************************************
 * brief    指针类型成员变量GetSet自动生成
 * param    type 类型
 * param    name 变量名
 * param    access_permission 权限
 * return   void
 ******************************************/
#define PointPropertyBuilderByName(type,name,access_permission)\
    access_permission:\
    type* m_##name;\
    public:\
    inline void set##name(type* v){m_##name = v;}\
    inline type* get##name(){return m_##name;}\

#define ParaToString(para) #para
//***************************************************************
enum DataType
{
    devType,
    sateType,
    target
};
//树形目录所需实现的接口
class treeItemInfo : public QObject
{
    Q_OBJECT
public:
    treeItemInfo(){}
    //获取树形目录节点id
    virtual QString GetTreeItemID() = 0;
    virtual QString GetTreeItemName() = 0;
    //获取节点是否可勾选
    virtual bool GetCheckAble() = 0;
    //获取节点勾选状态改变时要发送的信息
    virtual QString GetCheckChangeCode() = 0;
    //获取节点双击时需要发送的信息
    virtual QString GetDoubleClickCode() = 0;
    //状态序列号，默认是99
    int statusIndex = 99;
    //获取节点状态颜色
    virtual QString GetStatusColor()=0;
    //节点默认勾选状态
    Qt::CheckState checkstate = Qt::Unchecked;

};

enum DevStatus{
    good,
    partgood,
    bad
};
enum DevType{
    china,
    amerchine,
    itealily
};

//数据实体类
class DevStationData : public treeItemInfo
{
 public:
    DevStationData(){}
    ~DevStationData(){}
    bool operator ==(const DevStationData & value){
        return value.m_DevCode == m_DevCode ? true:false;
    }
    void operator =(const DevStationData & value){
        m_DevCode = value.m_DevCode;
        m_DevName = value.m_DevName;
        m_Status = value.m_Status;
        m_Type = value.m_Type;
    }
    PropertyBuilderByName(QString,DevName,private)
    PropertyBuilderByName(QString,DevCode,private)
    PropertyBuilderByName(DevStatus,Status,private)
    PropertyBuilderByName(QString,Type,private)
//树形目录接口实现
public:
    //获取节点id
    virtual QString GetTreeItemID() override{return "DevStationData"+m_DevCode;}
    virtual QString GetTreeItemName() override{return m_DevName;}
    //获取节点是否可勾选
    virtual bool GetCheckAble() override{return true;}
    //获取节点勾选状态改变时要发送的信息
    virtual QString GetCheckChangeCode()override{return m_DevCode;}
    //获取节点双击时需要发送的信息
    virtual QString GetDoubleClickCode()override{return m_DevCode;}
    //获取文本颜色
    virtual QString GetStatusColor(){
        QString color;
        switch (m_Status)
        {
        case DevStatus::good:
            color = QString("rgba(255,255,255,255)");
            break;
        case DevStatus::partgood:
            color = QString("rgba(255,0,0,255)");
            break;
        case DevStatus::bad:
            color = QString("rgba(127,127,127,255)");
            break;
        default:
            color = QString("rgba(255,255,255,255)");
            break;
        }
        statusIndex = (int)m_Status;
        return color;
    }
};


//Q_DECLARE_METATYPE(targetStruct)  //用来传递自定义结构体类型-在信号与槽中


#endif // DATASTRUCT_H
